<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
    <base href="<%=basePath%><%!private Object basePath;%>">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Amaze UI Admin index Examples</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="back/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="back/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="back/assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="back/assets/css/admin.css">
    <link rel="stylesheet" href="back/assets/css/app.css">
</head>

<body data-type="generalComponents">
<div>
    <div>
        <ol class="am-breadcrumb">
            <li><a href="back/right.jsp" class="am-icon-home">首页</a></li>
            <li class="am-active">用户列表</li>
        </ol>
        <div class="tpl-portlet-components">
            <div class="portlet-title">
                <div class="caption font-green bold">
                    用户列表
                </div>
            </div>
            <div class="tpl-block">
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-md-6">
                        <div class="am-btn-toolbar">
                            <div class="am-btn-group am-btn-group-xs">
                                <button type="button" class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span><a href="back/user-add.jsp"> 新增管理员</a></button>
                                <button type="button" class="am-btn am-btn-default am-btn-secondary"><span class="am-icon-save"></span> 保存</button>
                                <button type="button" class="am-btn am-btn-default am-btn-danger"><span class="am-icon-trash-o"></span> 删除</button>
                            </div>
                        </div>
                    </div>
                    <div class="am-u-sm-12 am-u-md-3">
                        <div class="am-form-group">
                            <select data-am-selected="{btnSize: 'sm'}">
                                <option value="option1">管理员</option>
                                <option value="option2">用户</option>
                            </select>
                        </div>
                    </div>
                    <div class="am-u-sm-12 am-u-md-3">
                        <div class="am-input-group am-input-group-sm">
                            <input type="text" class="am-form-field">
                            <span class="am-input-group-btn">
                                <button class="am-btn  am-btn-default am-btn-success tpl-am-btn-success am-icon-search" type="button"></button>
                            </span>
                        </div>
                    </div>
                </div>
                <div class="am-g">
                    <div class="am-u-sm-12">
                        <form class="am-form">
                            <table class="am-table am-table-striped am-table-hover table-main">
                                <thead>
                                    <tr>
                                        <th class="table-check"><input type="checkbox" class="tpl-table-fz-check"></th>
                                        <th class="table-id">ID</th>
                                        <th class="table-title">用户名</th>
                                        <th class="table-type">注册时间</th>
                                        <th class="table-author am-hide-sm-only">手机号</th>
                                        <th class="table-date am-hide-sm-only">电子邮箱</th>
                                        <th class="table-set">操作</th>
                                    </tr>
                                </thead>
                                <tbody id="nbody">
                                <%--<tr>
                                    <td><input type="checkbox"></td>
                                    <td>1</td>
                                    <td><a href="#">Business management</a></td>
                                    <td>default</td>
                                    <td class="am-hide-sm-only">测试1号</td>
                                    <td class="am-hide-sm-only">2014年9月4日 7:28:47</td>
                                    <td>
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                <button class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 编辑</button>
                                                <button class="am-btn am-btn-default am-btn-xs am-hide-sm-only"><span class="am-icon-copy"></span> 复制</button>
                                                <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only"><span class="am-icon-trash-o"></span> 删除</button>
                                            </div>
                                        </div>
                                    </td>
                                </tr>--%>
                                </tbody>
                            </table>
                            <div class="am-cf">

                                <div class="am-fr">
                                    <ul class="am-pagination tpl-pagination">
                                        <li class="am-disabled"><a href="#">«</a></li>
                                        <li class="am-active"><a href="#">1</a></li>
                                        <li><a href="#">2</a></li>
                                        <li><a href="#">3</a></li>
                                        <li><a href="#">4</a></li>
                                        <li><a href="#">5</a></li>
                                        <li><a href="#">»</a></li>
                                    </ul>
                                </div>
                            </div>
                            <hr>

                        </form>
                    </div>
                </div>
            </div>
            <div class="tpl-alert"></div>
        </div>
    </div>
</div>


<script src="back/assets/js/jquery.min.js"></script>
<script src="back/assets/js/amazeui.min.js"></script>
<script src="back/assets/js/app.js"></script>
<script src="js/jquery-1.12.4.js"></script>
<script>
    $(function(){
        $.ajax({
             url:"../user/list.action",
             data:"",
             type:"get",
             dataType:"json",
             success:function(res){
                 console.log("ASD");
                for(var i=0;i<res.length;i++)
                {
                   var newtr=$("<tr></tr>");
                   newtr.append("<td><input type=\"checkbox\"></td>");
                   newtr.append("<td >"+res[i].id+"</td>");
                   newtr.append("<td class='am-hide-sm-only'>"+res[i].uname+"</td>");
                   newtr.append("<td>"+res[i].regdate+"</td>");
                   newtr.append("<td>"+res[i].phone+"</td>");
                   newtr.append("<td class=\"am-hide-sm-only\">"+res[i].email+"</td>");
                   newtr.append("<td>\<div class=\"am-btn-toolbar\">\n" +
                       "  <div class=\"am-btn-group am-btn-group-xs\">\n" +
                       "  <button class=\"am-btn am-btn-default am-btn-xs am-text-secondary\"> <a href=\"../user/selectById.action?id="+res[i].id+"\"><span class=\"am-icon-pencil-square-o\"></span>编辑</a></button>\n" +
                       "  <button class=\"am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only\" onclick='del("+res[i].id+")'><span class=\"am-icon-trash-o\"></span> 删除</button>\n" +
                       "  </div>\n</div>\n</td>");
                       $("#nbody").append(newtr);
                }
             },
            error:function (res) {
                console.log("asdgfj")
            }
         })
     });

    function  del(id) {
        if(confirm("你确定要删除这条数据吗？"))
        {
            console.log("jinru");
            location.href="../user/del.action?id="+id;
            console.log("user/del.action?id="+id);
//            window.href="user/del.action?id="+id;
        }
    }

</script>
</body>

</html>